<?php
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
|这里是您可以为应用程序注册API路由的地方。这些
|路由由组中的RouteServiceProvider加载
|被分配了“api”中间件组。享受构建API的乐趣！
|
*/

$api = app('Dingo\Api\Routing\Router');

//促销机小程序开放接口
$api->version('v1', function ($api) {
    $api -> group(['prefix' => 'bj'], function ($api) {
        $api->get('qrcode', function () {
            return "请使用小程序扫码";
        });
    });

    $api -> group(['prefix' => 'swt'], function ($api) {
        $api->get('qrcode', function () {
            return "请使用小程序扫码";
        });
    });

    $api -> group(['namespace' => 'App\Http\Controllers\Notify', 'prefix' => 'swt'], function ($api) {
        $api -> group(['prefix' => 'notify'], function ($api) {
            $api->post('wechat/order', 'WechatNotifyController@wechatOrder');

            $api->post('wechat/order/jsapi', 'WechatNotifyController@wechatJsApiOrder');

            $api->post('alipay/order', 'AlipayNotifyController@alipayOrder');

            $api->post('alipay/order/jsapi', 'AlipayNotifyController@alipayJsApiOrder');

            $api->post('orderInfo/dhe', 'DheNotifyController@DheOrderFinish');

            $api->post('bj/door','BjNotifyController@BjDoorStatus');

            $api->post('bj/video','BjNotifyController@BjVideoStatus');

            $api->post('bj/status','BjNotifyController@BjMachineStatus');

            $api->post('ty/machine','TyNotifyController@setMachineInfoResult');

            $api->post('ty/applyGoods','TyNotifyController@applyGoodsResult');

            $api->post('ty/videos','TyNotifyController@recognitionVideos');
        });
    });

    $api -> group(['namespace' => 'App\Http\Controllers', 'prefix' => 'swt'], function ($api) {

        $api -> group(['prefix' => 'login'], function ($api) {
            $api->get('loginByMiniWechat', 'LoginController@loginByMiniWechat');

            $api->get('getMobileByMiniWechat', 'LoginController@getMobileByMiniWechat');

            $api->get('loginByMiniAliPay', 'LoginController@loginByMiniAliPay');

            $api->get('getMobileByMiniAlipay', 'LoginController@getMobileByMiniAlipay');

            $api->get('getUserToken', 'LoginController@getUserToken');
        });

        $api -> group(['prefix' => 'user', 'middleware' => 'auth:sanctum'], function ($api) {

            $api->post('uploadAvatar', 'UserController@uploadAvatar');

            $api->post('setUserName', 'UserController@setUserName');

            $api->get('getUserInfo', 'UserController@getUserInfo');

            $api->get('logout', 'UserController@logout');
        });

        $api -> group(['prefix' => 'order'], function ($api) {

            $api->post('cancelWechatOrder', 'OrderController@cancelWechatOrder');

            $api -> group(['middleware' => 'auth:sanctum'], function ($api) {

                $api->post('createOrder', 'OrderController@createOrder');

                $api->post('getOrderStatus', 'OrderController@getOrderStatus');

                $api->get('getOrderFinish', 'OrderController@getOrderFinish');

                $api->get('getOrderDetail', 'OrderController@getOrderDetail');

                $api->get('getOrderList', 'OrderController@getOrderList');

                $api->post('setRefundOrder', 'OrderController@setRefundOrder');

                $api->get('getRefundOrderDetail', 'OrderController@getRefundOrderDetail');

                $api->post('payNeedFurtherOrder', 'OrderController@payNeedFurtherOrder');
            });
        });

        $api -> group(['prefix' => 'machine'], function ($api) {
            $api->get('getMachineInfo', 'MachineController@getMachineInfo');

            $api->get('getMachineGoods', 'MachineController@getMachineGoods');

            $api -> group(['middleware' => 'auth:sanctum'], function ($api) {

                $api->post('openDoor', 'MachineController@openDoor');

            });
        });

    });
});
